Testing (and using) your Singularity Container with Port Forwarding

Author

Daniel Kick

Published

June 7, 2023

Modified

June 7, 2023

Note: this how to guide assumes that you have a working container with jupyter installed. See this page for details on setting up the gpu.sif container used here.

There are two steps to access jupyter remotely. First, start jupyter in the container. This can be done like so

singularity exec --nv gpu.sif jupyter notebook --no-browser --port=8887

or can be started within a shell in the container if desired.

user.name$ singularity shell --nv gpu.sif
Singularity> jupyter notebook --no-browser --port=8887

Note that here the --nv flag is not needed if gpu access is not desired. Further we’re specifying a port to be used for the notebook.

If the above is being run on a remote machine that allows port forwarding then we can open a ssh session from the local machine to connect the remote port (8887) to a local port. Here we use the same port number but if that one is busy another could be used.

ssh -N -f -Y -L 8887:localhost:8887 labmember\@10.206.28.81

After this session is active, then you can interact with jupyter as you normally would.